import java.lang.*;
import java.io.*;

public class Add
 {
   private InputStreamReader ir=new InputStreamReader(System.in);
	private BufferedReader br,br1;
	private FileOutputStream fos;
	private	PrintStream ps; 
	private FileReader frs; 
        Generate g=new Generate(); 
          public void addMproduct()
	{
		String desc,name,rmrq;
		String id;
		double price=0;
		int stock=0,rol=0;
		 
		try
 		{
			id=g.generate_id("Item.txt");
			System.out.print("\n Product ID :"+id+"\n");
			br=new BufferedReader(ir);
			
			System.out.print("\n Product Name :");
			name=br.readLine();
                        
                        System.out.print("\n Product Discription :");
			desc=br.readLine();
                        
                        System.out.print("\n raw materials required(separated by  ;) :");
			rmrq=br.readLine();
			
			System.out.print("\n Unit Price : Rs.");
			price=Double.parseDouble(br.readLine());
			
			System.out.print("\n Starting stock value :");
			stock=Integer.parseInt(br.readLine());		
			
						
			fos=new FileOutputStream("Item.txt",true);
			ps=new PrintStream(fos);
			
			ps.println(id+","+name+","+desc+","+rmrq+","+price+","+stock);
			fos.close();
			System.out.println("Successfully added one product...");
		}
 		catch(Exception ex)
 		{
 			System.out.println("Error in accepting item specifications...");
 		}	
	}
            
         
	public void addInventoryItem()
	{
		String sname,rname;
		String id;
		double price=0;
		int stock=0,rol=0;
		
		try
 		{
			id=g.generate_id("InventoryItem.txt");
			System.out.print("\n Product ID :"+id+"\n");
			br=new BufferedReader(ir);
			
			System.out.print("\n Raw material Name :");
			rname=br.readLine();
                        
                        System.out.print("\n Supplier Name :");
			sname=br.readLine();
			
			System.out.print("\n Unit Price : Rs.");
			price=Double.parseDouble(br.readLine());
			
			System.out.print("\n Starting stock value :");
			stock=Integer.parseInt(br.readLine());		 

                        System.out.print("\n Re-order Level :");
			rol=Integer.parseInt(br.readLine());			
						
			fos=new FileOutputStream("InventoryItem.txt",true);
			ps=new PrintStream(fos);
			
			ps.println(id+","+rname+","+sname+","+price+","+stock+","+rol);
			fos.close();
			System.out.println("Successfully added one product...");
		}
 		catch(Exception ex)
 		{
 			System.out.println("Error in accepting item specifications...");
 		}	
	}
	

 }
